package com.dfbz.TCP;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //开启服务器
        ServerSocket serverSocket = new ServerSocket(8888);
        //接受客户端的消息
        Socket accept = serverSocket.accept();
        InputStream inputStream = accept.getInputStream();
        //读客户端的消息
        byte[] data=new byte[1024];
        int read = inputStream.read(data);
        System.out.println("服务端:"+new String(data,0,read));
        //向客户端发消息
        OutputStream outputStream = accept.getOutputStream();
        String str="a";
        outputStream.write(Integer.parseInt(str));
    }
}
